﻿

using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Profile;
using System.Data;
using System.Text;
using Gift.Model.ENUM;

using Gift.DAL;
using Gift.Model;
using Gift.Utile;

namespace WebSite.admin.Report
{
    public partial class CardReport : BaseAdmin
    {
        readonly dalCompany theCompany = new dalCompany();
        readonly Card theCard = new Card();

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.GridView1.PageIndex = this.ddlCurrentPage.SelectedIndex;
            this.GridViewBind("");
        }

        private string GetSql(bool isSum)
        {
            StringBuilder sbSql = new StringBuilder();

            string sCardCoumns = "count(ct.[name]) as 领用数,sum(case when c.states in (1,2,5)  then 1 else 0 end ) as 激活数,"
                            + " sum(case when c.states =2   then 1 else 0 end ) as 已使用数,"
                            + " sum(case when c.states in (1,5)  then 1 else 0 end ) as 未使用数,"
                            + " sum(case when c.states =6   then 1 else 0 end ) as 申请激活中,"
                            + " sum(case when c.states =4   then 1 else 0 end ) as 已领用未激活,"
                            + " sum(case when c.states in (1,5) and convert(datetime, convert(varchar(10), getdate(),121))  > convert(datetime, convert(varchar(10), endtime,121)) then 1 else 0 end ) as 已失效数,"
                            + " sum(case when c.states =3   then 1 else 0 end ) as 被禁用数 ";

            if (this.ddlCardStates.SelectedItem.Value == "0")
            {
                sCardCoumns = " count(ct.[name]) as 领用数";
            }
            else if (this.ddlCardStates.SelectedItem.Value == "1")
            {
                sCardCoumns = " sum(case when c.states in (1,2,5)  then 1 else 0 end ) as 激活数";
            }
            else if (this.ddlCardStates.SelectedItem.Value == "2")
            {
                sCardCoumns = " sum(case when c.states =2   then 1 else 0 end ) as 已使用数 ";
            }
            else if (this.ddlCardStates.SelectedItem.Value == "3")
            {
                sCardCoumns = "  sum(case when c.states =3   then 1 else 0 end ) as 被禁用数 ";
            }
            else if (this.ddlCardStates.SelectedItem.Value == "4")
            {
                sCardCoumns = " sum(case when c.states =4   then 1 else 0 end ) as 已领用未激活 ";
            }
            else if (this.ddlCardStates.SelectedItem.Value == "6")
            {
                sCardCoumns = " sum(case when c.states =6   then 1 else 0 end ) as 申请激活中 ";
            }

            string strWhereLevel = string.Empty;

            if (this.ddlLevleResult.SelectedItem.Value == "1")
            {
                strWhereLevel = " and isnull(c.CompanyId,'') != '' and isnull(c.IICompanyId,'') = '' and isnull(c.IIICompanyId,'') = '' and isnull(c.IVCompanyId,'') = '' ";
            }
            else if (this.ddlLevleResult.SelectedItem.Value == "2")
            {
                strWhereLevel = " and isnull(c.IICompanyId,'') != '' and isnull(c.IIICompanyId,'') = '' and isnull(c.IVCompanyId,'') = '' ";
            }
            else if (this.ddlLevleResult.SelectedItem.Value == "3")
            {
                strWhereLevel = " and isnull(c.IIICompanyId,'') != '' and isnull(c.IVCompanyId,'') = '' ";
            }
            else if (this.ddlLevleResult.SelectedItem.Value == "4")
            {
                strWhereLevel = " and isnull(c.IVCompanyId,'') != '' ";
            }

            if (this.ddlCardStates.SelectedItem.Value == "1" || this.ddlCardStates.SelectedItem.Value == "2")
            {
                if (this.dateFrom.Value != "")
                {
                    strWhereLevel = strWhereLevel + string.Format(" and states in (1,2,5) and   convert(varchar(10),opentime,121) >= convert(varchar(10),'{0}',121) ", this.dateFrom.Value);
                }
                if (this.dateTo.Value != "")
                {
                    strWhereLevel = strWhereLevel + string.Format(" and states in (1,2,5) and   convert(varchar(10),opentime,121) <= convert(varchar(10),'{0}',121) ", this.dateTo.Value);
                }
            }
            else if (this.ddlCardStates.SelectedItem.Value == "2")
            {
                if (this.dateFrom.Value != "")
                {
                    strWhereLevel = strWhereLevel + string.Format(" and states =2 and   convert(varchar(10),UsedTime,121) >= convert(varchar(10),'{0}',121) ", this.dateFrom.Value);
                }
                if (this.dateTo.Value != "")
                {
                    strWhereLevel = strWhereLevel + string.Format(" and states =2 and   convert(varchar(10),UsedTime,121) <= convert(varchar(10),'{0}',121) ", this.dateTo.Value);
                }
            }
            else if (this.ddlCardStates.SelectedItem.Value == "3")
            {
                if (this.dateFrom.Value != "")
                {
                    strWhereLevel = strWhereLevel + string.Format(" and states =3 and   convert(varchar(10),DisableTime,121) >= convert(varchar(10),'{0}',121) ", this.dateFrom.Value);
                }
                if (this.dateTo.Value != "")
                {
                    strWhereLevel = strWhereLevel + string.Format(" and states =3 and   convert(varchar(10),DisableTime,121) <= convert(varchar(10),'{0}',121) ", this.dateTo.Value);
                }
            }
            else if (this.ddlCardStates.SelectedItem.Value == "4")
            {
                if (this.dateFrom.Value != "")
                {
                    strWhereLevel = strWhereLevel + string.Format(" and states =4 and   convert(varchar(10),AreadyPublishNoOpenTime,121) >= convert(varchar(10),'{0}',121) ", this.dateFrom.Value);
                }
                if (this.dateTo.Value != "")
                {
                    strWhereLevel = strWhereLevel + string.Format(" and states =4 and   convert(varchar(10),AreadyPublishNoOpenTime,121) <= convert(varchar(10),'{0}',121) ", this.dateTo.Value);
                }
            }
            else if (this.ddlCardStates.SelectedItem.Value == "6")
            {
                if (this.dateFrom.Value != "")
                {
                    strWhereLevel = strWhereLevel + string.Format(" and states =6 and   convert(varchar(10),ApplicationOpenTime,121) >= convert(varchar(10),'{0}',121) ", this.dateFrom.Value);
                }
                if (this.dateTo.Value != "")
                {
                    strWhereLevel = strWhereLevel + string.Format(" and states =6 and   convert(varchar(10),ApplicationOpenTime,121) <= convert(varchar(10),'{0}',121) ", this.dateTo.Value);
                }
            }

            string sql = string.Empty;
            if (base.AdminTypeId == "1" && string.IsNullOrEmpty(this.ddlCompany.SelectedItem.Value))
            {
                string sCompanyIds = GetCompanyListString();
                if (sCompanyIds != string.Empty)
                {
                    sql = sql + string.Format(" and (c.companyId in ({0}) or c.IICompanyId in ({0}) or c.IIICompanyId in ({0}) or c.IVCompanyId in ({0}))"
                                               , sCompanyIds);
                }
            }
            else if (base.CompanyId != null && string.IsNullOrEmpty(this.ddlCompany.SelectedItem.Value))
            {
                sql = sql + string.Format(" and (c.companyId={0} or c.IICompanyId={0} or c.IIICompanyId={0} or c.IVCompanyId={0})"
                                           , base.CompanyId);
            }
            else if (this.ddlCompany.SelectedItem.Value.Trim() != "")
            {
                sql = sql + string.Format(" and (c.companyId={0} or c.IICompanyId={0} or c.IIICompanyId={0} or c.IVCompanyId={0})"
                                           , this.ddlCompany.SelectedItem.Value.Trim());
            }

            if (isSum)
            {
                if (this.rblShowType.SelectedItem.Value == "1")
                {
                    sbSql.AppendFormat("select   "
                                + " '' as 卡片名称,"
                                + " '' as 发行方式,"
                                + " null as 面额,"
                                 + sCardCoumns

                                + " from db_Card c inner join tbCardType ct on c.CardTypeId = ct.id join  tbProfessionAreaType pt on ct.ProfessionAreaTypeId=pt.id"
                                     + " {0}  {1} {2} "

                             , strWhereLevel
                            , this.ddlCardType.SelectedItem.Value == "" ? "" : " and ct.id = " + this.ddlCardType.SelectedItem.Value
                            , sql);
                }
                else
                {
                    sbSql.AppendFormat("select   "
                              + " '合计' as 公司简称 ,"
                                + " '' as 卡片名称,"
                                + " '' as 发行方式,"
                                + " null as 面额,"
                                + sCardCoumns

                                + " from db_Card c inner join tbCardType ct on c.CardTypeId = ct.id join  tbProfessionAreaType pt on ct.ProfessionAreaTypeId=pt.id"
                                     + " {0}  {1} {2} "

                             , strWhereLevel
                            , this.ddlCardType.SelectedItem.Value == "" ? "" : " and ct.id = " + this.ddlCardType.SelectedItem.Value
                            , sql);
                }
            }
            else
            {
                if (this.rblShowType.SelectedItem.Value == "1")
                {
                    sbSql.AppendFormat("select   "
                                  + " ct.[name] as 卡片名称,"
                                  + " c.PublishWay as 发行方式,"
                                  + " c.CardPrice as 面额,"
                                  +  sCardCoumns

                                  + " from db_Card c inner join tbCardType ct on c.CardTypeId = ct.id join  tbProfessionAreaType pt on ct.ProfessionAreaTypeId=pt.id"
                                       + " {0}  {1} {2} "

                                  + " group by  ct.[name],c.PublishWay,c.CardPrice,ct.id"

                               , strWhereLevel
                              , this.ddlCardType.SelectedItem.Value == "" ? "" : " and ct.id = " + this.ddlCardType.SelectedItem.Value
                              , sql);
                }
                else
                {
                    sbSql.AppendFormat("select   "
                                  + " (select CompanyShortName from tbCompany where Id=c.companyId  ) + '->' + isnull((select CompanyShortName from tbCompany where Id=c.IICompanyId  ),' ') + '->' + isnull((select CompanyShortName from tbCompany where Id=c.IIICompanyId  ),' ') + '->' + isnull((select CompanyShortName from tbCompany where Id=c.IVCompanyId  ),' ') as 公司简称 ,"
                                    + " ct.[name] as 卡片名称,"
                                    + " c.PublishWay as 发行方式,"
                                    + " c.CardPrice as 面额,"
                                    +  sCardCoumns
                                    + " from db_Card c inner join tbCardType ct on c.CardTypeId = ct.id join  tbProfessionAreaType pt on ct.ProfessionAreaTypeId=pt.id"
                                         + " {0}  {1} {2} "

                                    + " group by ct.[name],c.PublishWay,c.CompanyId,c.IICompanyId,C.IIICompanyId,C.IVCompanyId,c.CardPrice,ct.id"

                                 , strWhereLevel
                                , this.ddlCardType.SelectedItem.Value == "" ? "" : " and ct.id = " + this.ddlCardType.SelectedItem.Value
                                , sql);
                }
            }

            return sbSql.ToString(); ;
        }

        private void BindProfessionAreaType()
        {
            //DataSet dsType = new DataSet();
            //DALProfessionAreaType theType = new DALProfessionAreaType();
            //if (!string.IsNullOrEmpty(base.CompanyId))
            //{
            //    dsType = theType.GetListByCompanyId(base.CompanyId);
            //}
            //else
            //{
            //    dsType = theType.GetList(string.Empty);
            //}
            //if (dsType.Tables.Count > 0)
            //{
            //    this.ddlProfessionAreaType.DataSource = dsType.Tables[0].DefaultView;
            //    this.ddlProfessionAreaType.DataTextField = "Name";
            //    this.ddlProfessionAreaType.DataValueField = "Id";
            //    this.ddlProfessionAreaType.DataBind();
            //}
            //this.ddlProfessionAreaType.Items.Insert(0, new ListItem("所属专区", ""));

        }

        void BindProvenctList()
        {
            DataSet ds = theCompany.GetProvenceList();
            this.ddlProvence.DataTextField = "provence";
            this.ddlProvence.DataValueField = "provence";
            this.ddlProvence.DataSource = ds;
            this.ddlProvence.DataBind();
            this.ddlProvence.Items.Insert(0, new ListItem("请选择省份",""));
        }

        string GetCompanyListString()
        {
            System.Text.StringBuilder sResult = new System.Text.StringBuilder();
            foreach (ListItem it in this.ddlCompany.Items)
            {
                if (it.Value != string.Empty)
                {
                    sResult.Append(it.Value + ",");
                }
            }
            if (sResult.Length > 0)
            {
                return sResult.ToString().Substring(0, sResult.Length - 1);
            }
            return string.Empty;
        }


        void BindCompanyList()
        {
            DataTable dt;
            string sWhere = " 1=1 ";
            dt = theCompany.GetList(sWhere).Tables[0];
            DataTable dtResult = new DataTable();
            DataColumn dcId = new DataColumn("Id", Type.GetType("System.String"));
            DataColumn dcName = new DataColumn("Name", Type.GetType("System.String"));
            DataColumn dcLevelId = new DataColumn("LevelID", Type.GetType("System.String"));
            DataColumn dcProvence = new DataColumn("Provence", Type.GetType("System.String"));
            dtResult.Columns.Add(dcId);
            dtResult.Columns.Add(dcName);
            dtResult.Columns.Add(dcLevelId);
            dtResult.Columns.Add(dcProvence);

            DataTable dtTemp = new DataTable();
            DataRow drTemp;

            if (base.AdminTypeId == ((int)Gift.Model.ENUM.EAdminType.Salesman).ToString())
            {
                DataSet ds = theCompany.GetCompanyAdminList(base.AdminUserId);
                if (ds != null && ds.Tables.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        dtTemp = GetAllCompany(dt, null, int.Parse(dr["CompanyId"].ToString()), true);
                        foreach (DataRow drResult in dtTemp.Rows)
                        {
                            drTemp = dtResult.NewRow();
                            drTemp["Id"] = drResult["Id"].ToString();
                            drTemp["Name"] = drResult["Name"].ToString();
                            drTemp["LevelID"] = drResult["LevelID"].ToString();
                            drTemp["Provence"] = drResult["Provence"].ToString();
                            dtResult.Rows.Add(drTemp);
                        }
                    }
                }
            }

            else if (base.CompanyId != null)
            {
                dtResult = GetAllCompany(dt, null, int.Parse(base.CompanyId), true);
            }
            else
            {
                dtResult = GetAllCompany(dt, null, 0, true);
            }

            string sFiler = string.Empty;
            if (this.ddlLevel.SelectedItem.Value != "")
            {
                sFiler = " LevelID = " + this.ddlLevel.SelectedItem.Value;
            }
            if (this.ddlProvence.SelectedItem.Value != "")
            {
                sFiler = sFiler == string.Empty ? " Provence = '" + this.ddlProvence.SelectedItem.Value + "'" : sFiler + " and Provence = '" + this.ddlProvence.SelectedItem.Value + "'";
            }

            dtResult.DefaultView.RowFilter = sFiler;

            this.ddlCompany.DataTextField = "Name";
            this.ddlCompany.DataValueField = "Id";
            this.ddlCompany.DataSource = dtResult.DefaultView;
            this.ddlCompany.DataBind();

            this.ddlCompany.Items.Insert(0, new ListItem("请选择商家...", ""));
 
        }

        void BindCompanyLevel()
        {
            DataSet ds = theCompany.GetCompanyLevelList();
            if (base.CompanyId != null && base.AdminTypeId != "1")
            {
                ds.Tables[0].DefaultView.RowFilter = " Id >= " + base.CompanyLevelId;
            } 

            this.ddlLevel.DataTextField = "LevelName";
            this.ddlLevel.DataValueField = "Id";
            this.ddlLevel.DataSource = ds.Tables[0].DefaultView;
            this.ddlLevel.DataBind();
            this.ddlLevel.Items.Insert(0, new ListItem("请选择商家级别...", ""));

            this.ddlLevleResult.DataTextField = "LevelName";
            this.ddlLevleResult.DataValueField = "Id";
            this.ddlLevleResult.DataSource = ds.Tables[0].DefaultView;
            this.ddlLevleResult.DataBind();
            this.ddlLevleResult.Items.Insert(0, new ListItem("请选择筛选级别...", ""));

        }

        private void GridViewBind(string sqlSort)
        {
            string sql = GetSql(false);

            string sqlStat = GetSql(true);

            DataTable tbStat = SQLAccess.GreatDs(sqlStat).Tables[0];

            if (sqlSort == "")
            {
                //sql = sql + " order by 日期 desc ";
            }
            else
            {
                sql = sql + sqlSort;
            }
            DataTable table = new DataTable();
            table = SQLAccess.GreatDs(sql).Tables[0];

            DataRow drValue = table.NewRow();

            if (tbStat != null && tbStat.Rows.Count > 0)
            {
                drValue.ItemArray = tbStat.Rows[0].ItemArray;
                table.Rows.InsertAt(drValue, 0);
 
            }
            string sFilter = string.Empty;
            if (this.ddlCardStates.SelectedItem.Value == "1")
            {
                sFilter = "  激活数 > 0";
            }
            else if (this.ddlCardStates.SelectedItem.Value == "2")
            {
            
                sFilter = "  已使用数 > 0";
            }
            else if (this.ddlCardStates.SelectedItem.Value == "3")
            {
                sFilter = "  被禁用数 > 0";
            }
            else if (this.ddlCardStates.SelectedItem.Value == "4")
            {
                sFilter = "  已领用未激活 > 0";
            }
            else if (this.ddlCardStates.SelectedItem.Value == "6")
            {
                sFilter = "  申请激活中 > 0";
            }

            table.DefaultView.RowFilter = sFilter;
            this.GridView1.DataSource = table.DefaultView;
            this.GridView1.DataBind();
            this.LblCurrentIndex.Text = "当前第 " + ((this.GridView1.PageIndex + 1)).ToString() + "页";
            this.LblPageCount.Text = "共 " + this.GridView1.PageCount.ToString() + "页";
            this.LblRecordCount.Text = "总计 " + table.DefaultView.Count.ToString() + "个记录";
            if (table.DefaultView.Count == 0)
            {
                this.btnFirst.Visible = false;
                this.btnPrev.Visible = false;
                this.btnNext.Visible = false;
                this.btnLast.Visible = false;
                this.LblCurrentIndex.Visible = false;
                this.LblPageCount.Visible = false;
                this.LblRecordCount.Visible = false;
            }
            else if (this.GridView1.PageCount == 1)
            {
                this.btnFirst.Visible = false;
                this.btnPrev.Visible = false;
                this.btnNext.Visible = false;
                this.btnLast.Visible = false;
            }
            this.btnFirst.CommandName = "1";
            this.btnPrev.CommandName = (this.GridView1.PageIndex == 0) ? "1" : this.GridView1.PageIndex.ToString();
            this.btnNext.CommandName = (this.GridView1.PageCount == 1) ? this.GridView1.PageCount.ToString() : ((this.GridView1.PageIndex + 2)).ToString();
            this.btnLast.CommandName = this.GridView1.PageCount.ToString();
            this.ddlCurrentPage.Items.Clear();
            if (this.GridView1.PageCount > 0)
            {
                for (int i = 1; i <= this.GridView1.PageCount; i++)
                {
                    this.ddlCurrentPage.Items.Add(i.ToString());
                }
                this.ddlCurrentPage.SelectedIndex = this.GridView1.PageIndex;
            } 
        }
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!base.IsPostBack)
            {
                if (string.IsNullOrEmpty(base.CompanyId))
                {
                    base.ValidateLoginRule(ERule.CardStat);
                }
                this.BindProfessionAreaType();
                this.BindCompanyLevel();
                this.BindProvenctList();
                this.BindCardType();
                //this.BindCardStates();
                this.BindCompanyList();
            }
        }

        protected void PagerButtonClick(object sender, EventArgs e)
        {
            this.GridView1.PageIndex = Convert.ToInt32(((LinkButton)sender).CommandName) - 1;
            this.GridViewBind("");
        }

        protected void ibtnSearch_Click(object sender, ImageClickEventArgs e)
        {
            this.GridViewBind("");
        }


        protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
        {
            if (ViewState["Ascending"] == null)
            {
                ViewState["Ascending"] = " desc ";
                this.GridViewBind(" order by " + e.SortExpression + " asc ");
            }
            else
            {
                this.GridViewBind(" order by " + e.SortExpression + ViewState["Ascending"].ToString());
                if (ViewState["Ascending"].ToString() == " asc ")
                {
                    ViewState["Ascending"] = " desc ";
                }
                else
                {
                    ViewState["Ascending"] = " asc ";
                }
            }

        }

        protected void ibtnExport_Click(object sender, ImageClickEventArgs e)
        {
            string fileName = DateTime.Now.ToString("yyyyMMddhhmmss") + ".csv";//设置导出文件的名称   
            string sql = GetSql(false);

            DataTable table = new DataTable();
            table = SQLAccess.GreatDs(sql).Tables[0];
            string sTitle = string.Empty;
           
                sTitle = " 卡片统计表";
           
            Gift.Utile.OperateExcel.ExportCSVWithTitle(table, fileName, sTitle);
        }



        //void ViewChart(DataTable dtChart)
        //{


        //    if (this.ddlTimeType.SelectedItem.Value == "2")
        //    {
        //        string sTitle = this.ddlYear.SelectedItem.Value + "年" + "卡片状态数量统计(月)";

        //        string[] xNames = new string[dtChart.Rows.Count];
        //        double[] yVal1 = new double[dtChart.Rows.Count];
        //        double[] yVal2 = new double[dtChart.Rows.Count];
        //        double[] yVal3 = new double[dtChart.Rows.Count];

        //        int m = 0;
        //        for (int i = dtChart.Rows.Count - 1; i >= 0; i--)
        //        {
        //            xNames[m] = int.Parse(dtChart.Rows[i][0].ToString().Substring(5, 2)).ToString() + "月";
        //            yVal1[m] = double.Parse(dtChart.Rows[i][2].ToString());
        //            yVal2[m] = double.Parse(dtChart.Rows[i][3].ToString());
        //            yVal3[m] = double.Parse(dtChart.Rows[i][4].ToString());
        //            m++;

        //        }

        //    }
        //    else
        //    {
        //        string sTitle = this.ddlYear.SelectedItem.Value + "年" + "卡片状态数量统计(天)";

        //        string[] xNames = new string[dtChart.Rows.Count];
        //        double[] yVal1 = new double[dtChart.Rows.Count];
        //        double[] yVal2 = new double[dtChart.Rows.Count];
        //        double[] yVal3 = new double[dtChart.Rows.Count];

        //        int m = 0;
        //        for (int i = dtChart.Rows.Count - 1; i >= 0; i--)
        //        {
        //            xNames[m] = dtChart.Rows[i][0].ToString();
        //            yVal1[m] = double.Parse(dtChart.Rows[i][2].ToString());
        //            yVal2[m] = double.Parse(dtChart.Rows[i][3].ToString());
        //            yVal3[m] = double.Parse(dtChart.Rows[i][4].ToString());
        //            m++;

        //        }

        //    }
        //}

        //protected void ddlProfessionAreaType_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    if (!string.IsNullOrEmpty(this.ddlProfessionAreaType.SelectedItem.Value))
        //    {
        //        DataSet dsType = new DataSet();
        //        DALCardType theType = new DALCardType();
        //        dsType = theType.GetList(" ProfessionAreaTypeId = " + this.ddlProfessionAreaType.SelectedItem.Value);
        //        if (dsType.Tables.Count > 0)
        //        {
        //            this.ddlCardType.DataSource = dsType.Tables[0].DefaultView;
        //            this.ddlCardType.DataTextField = "Name";
        //            this.ddlCardType.DataValueField = "Id";
        //            this.ddlCardType.DataBind();
        //        }
        //        this.ddlCardType.Items.Insert(0, new ListItem("请选择卡片类型", ""));
        //    }
        //}

        void BindCardType()
        {
            DataSet dsType = new DataSet();
            DALCardType theType = new DALCardType();
            dsType = theType.GetList("");
            if (dsType.Tables.Count > 0)
            {
                this.ddlCardType.DataSource = dsType.Tables[0].DefaultView;
                this.ddlCardType.DataTextField = "Name";
                this.ddlCardType.DataValueField = "Id";
                this.ddlCardType.DataBind();
            }
            this.ddlCardType.Items.Insert(0, new ListItem("所请选择卡片类型", ""));
        }

        //void BindCardStates()
        //{
        //    DataSet dsCard = theCard.GetCardStateList();
        //    this.ddlCardStates.DataTextField = "Name";
        //    this.ddlCardStates.DataValueField = "Id";
        //    if (dsCard != null && dsCard.Tables.Count > 0)
        //    {
        //         dsCard.Tables[0].DefaultView.RowFilter = " Id <> 0 ";
        //        this.ddlCardStates.DataSource = dsCard.Tables[0].DefaultView;
        //        this.ddlCardStates.DataBind();
        //        this.ddlCardStates.Items.Insert(0, new ListItem("请选择卡片状态", ""));
        //    }
        //}

        protected void ddlLevel_SelectedIndexChanged(object sender, EventArgs e)
        {
            BindCompanyList();
        }

        protected void ddlProvence_SelectedIndexChanged(object sender, EventArgs e)
        {
            BindCompanyList();
        }


    }
}